package com.micro.boot.container;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

/**
 * 
 * @Description: 自定义tomcat错误页面
 * @param     
 * @throws
 * @author renweiping
  *@e_mail renweiping_1113@google.com
 * @date 2018年9月18日
 */
@Component
public class ContainerCustomizer implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {

	public void customize(ConfigurableServletWebServerFactory server) {
        ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
        ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");
        ErrorPage error400Page = new ErrorPage(HttpStatus.BAD_REQUEST, "/400.html");
		server.addErrorPages(error404Page);
		server.addErrorPages(error500Page);
		server.addErrorPages(error400Page);
	}
	
}